set more off
clear all

use "$path_data/temp/followup_student_baseline_score_missing_dummy", clear
merge 1:1 student_no using "$path_data/temp/endline_followup_parents_data_1stchild"
rename _merge _merge_1st
rename hhmember hhmember_1st
rename hhheadage hhheadage_1st
rename hhheadeduyear hhheadeduyear_1st

merge 1:1 student_no using "$path_data/temp/endline_followup_parents_data_2ndchild"
rename _merge _merge_2nd
rename hhmember hhmember_2nd
rename hhheadage hhheadage_2nd
rename hhheadeduyear hhheadeduyear_2nd

merge 1:1 student_no using "$path_data/temp/endline_followup_parents_data_3rdchild"
rename _merge _merge_3rd
rename hhmember hhmember_3rd
rename hhheadage hhheadage_3rd
rename hhheadeduyear hhheadeduyear_3rd

recode hhmember* hhheadage* hhheadeduyear* (. = 0) 

gen hhmember = hhmember_1st + hhmember_2nd + hhmember_3rd
gen hhheadage = hhheadage_1st + hhheadage_2nd + hhheadage_3rd
gen hhheadeduyear = hhheadeduyear_1st + hhheadeduyear_2nd + hhheadeduyear_3rd

keep if attrition == 0

save "$path_data/temp/followup_student_parents_matched", replace
